﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class Game : MonoBehaviour
{
    public static Game Instance { get; private set; }

    [SerializeField]
    public MonsterFactory monsterFactory;

    public Scene scene;

    public int RandomMonsterNum = 10;
    
    private void Start()
    {
        while(Mgr.monsterMgr.monsterList.Length < RandomMonsterNum)
        {
            Mgr.monsterMgr.CreateMonster(EnumMonster.Ghost);
        }

        Cursor.visible = true;
    }

    private void Awake()
    {
        scene = SceneManager.GetSceneByName(name);
        Instance = this;
    }
    

    private void Update()
    {
        //鼠标选中
        if(Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out RaycastHit hit, 20f))
            {
                GameObject go = hit.collider.gameObject;
                if(go.GetComponent<Monster>() != null)
                {
                    Mgr.selectTargetMgr.SetSelectTarget(go.GetComponent<Monster>());
                    Debug.Log(go.name);
                }
                
            }
            
        }

        Mgr.monsterMgr.monsterList.GameUpdate();

    }

}
